<div class="container" style="margin-top: 40px;">
    <form class="form-inline">
        <div class="midbox">
            <?php $this->component('Hr_SelectDePartMent');?>
            <button type="submit" class="btn btn-small">搜索</button>
            <div class="btn-group" style="float: right;">
                <!--<button class="btn btn-small disabled" disabled>共有<?=$data['dep_count']?>个部门</button>-->
                <span class="btn btn-small disabled" style="cursor:default;">共有<?=$data['dep_count']?>个部门</span>
                <button class="btn btn-primary btn-small" data-toggle="modal" data-target="#myModal">添加部门</button>
            </div>
        </div>
    </form>

    <table class="midbox table" style="margin-top: 20px;">
        <thead>
        <tr>
            <th>ID</th>
            <th>部门名称</th>
            <th>成本计入</th>
            <th style="min-width: 100px">计划编制</th>
            <th>部门属性</th>
            <th style="width:25px;">&nbsp;</th>
        </tr>
        </thead>
        <?php if($data['dep_list']):?>
        <tbody>
        <?php foreach($data['dep_list'] as $val):?>
        <tr>
            <td><?=$val['department_id']?></td>
            <td class="depart"><?=$val['department_name']?></td>
            <td class="costcity"><?=$val['cost_city_name']?></td>
            <td class="formation"><?=$val['plan_num']?></td>
            <td><?=$val['city_name']?>/<?=$val['bu_name']?>/<?=$val['function_name']?></td>
            <td><i style="display: none" class="depart_num"><?=$val['fact_num']?></i><i style="height:18px; width:20px;" class="delete icon-trash"></i></td>

        </tr>
        <?php endforeach;?>
        </tbody>
        <?php endif;?>
    </table>

    <div class="pagination pagination-centered">
        <?php if(isset($data['multipage']) && !empty($data['multipage']['list'])) {?>
        <?php $this->component('Hr_MultiPage', array('multipage'=>$data['multipage'])); ?>
        <?php } ?>
    </div>
</div>

<?php /*添加部门 BEGIN*/?>
<div class="modal fade panel" id="myModal" style="display:none;">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">&times;</a>
        <h5>添加部门</h5>
    </div>

    <form id="departForm" action="" class="form-inline">
        <ul class="modal-body ul_add">
            <li>
                <div class="control-group">
                    <label class="control-label">部门属性：</label>

                    <div class="controls" style="display: inline-block;">
                        <select name="company">
                            <?php foreach($selectdata['company'] as $val):?>
                            <option value="<?=$val['company_id']?>"><?=$val['company_name']?></option>
                            <?php endforeach;?>
                        </select>
                        <select name="city" id="city" class="{min:0,messages:{min:''}}">
                            <option value="-1">-城市-</option>
                            <?php foreach($selectdata['citylist'] as $city_id=>$val):?>
                            <option value="<?=$city_id?>"
                            <?php if($de_city_id==$city_id):?>selected="selected"<?php endif;?>><?=$val?></option>
                            <?php endforeach;?>
                        </select>
                        <select name="buit" class="{min:0,messages:{min:''}}">
                            <option value="-1">-事业部-</option>
                            <?php foreach($selectdata['business'] as $val):?>
                            <option value="<?=$val['bu_id']?>"
                            <?php if($de_bu_id==$val['bu_id']):?>selected="selected"<?php endif;?>><?=$val['bu_name']?></option>
                            <?php endforeach;?>
                        </select>
                        <select name="skill" id="skill" class="{min:0,messages:{min:''}}">
                            <option value="-1">-职能-</option>
                            <?php foreach($selectdata['function'] as $val):?>
                            <option value="<?=$val['function_id']?>"
                            <?php if($de_function_id==$val['function_id']):?>selected="selected"<?php endif;?>><?=$val['function_name']?></option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
            </li>
            <li>
                <div class="control-group">
                    <label class="control-label">部门名称：</label>

                    <div class="controls" style="display: inline-block;">
                        <input type="text" id="depart" name="depart" class="{required:true,messages:{required:'请输入部门名称'}}"/>
                    </div>
                </div>
                <!--<em>部门名称：</em>-->
                <!--<input type="text" id="depart" name="depart" class="{required:true,messages:{required:'请输入部门名称'}}"/>-->
            </li>
            <li>
                <div class="control-group">
                    <label class="control-label">成本计入：</label>

                    <div class="controls" style="display: inline-block;">
                        <select name="cost" id="cost">
                            <option value="0">&ndash;城市&ndash;</option>
                            <?php foreach($selectdata['citylist'] as $city_id=>$val):?>
                            <option value="<?=$city_id?>"
                            <?php if($de_city_id==$city_id):?>selected="selected"<?php endif;?>><?=$val?></option>
                            <?php endforeach;?>
                        </select>
                    </div>
                </div>
            </li>
            <li>
                <div class="control-group">
                    <label class="control-label">计划编制：</label>

                    <div class="controls" style="display: inline-block;">
                        <input name="formation" type="text" maxlength="6" class="{digits:true,range:[0,100000],messages:{digits:'请输入100000以内的数字',range:'请输入100000以内的数字'}} span1"/> 人
                    </div>
                </div>
                <!--<em>计划编制：</em>-->
                <!--<input name="formation" type="text" class="{digits:true,max:1000,messages:{digits:'请输入1000以内的数字',max:'请输入1000以内的数字'}}"/>人-->
            </li>
            <li>
                <div class="control-group">
                    <label class="control-label" style="margin: 0 0 0 67px;">&nbsp;</label>

                    <div class="controls" style="display: inline-block;">
                        <input type="submit" value="保存" id='sub' class="btn btn-primary"/>
                        <input type="button" value="取消" class="btn" data-dismiss="modal"/>
                    </div>
                </div>
                <div id="err" style="margin: 0 0 0 73px; float: left; display: none" class="alert alert-error fade in"></div>
            </li>
        </ul>
    </form>
</div>
<?php /*添加部门 END*/?>

<!--弹出窗口begain-->
<div id="confirmDialog" class="modal hide dialog" >
    <div class="modal-header">
        <a class="close" data-dismiss="modal">&times;</a>
        <h5 style="color: #555;">提示信息</h5>
    </div>
    <div class="modal-body" style="text-align: center; padding: 15px; 0 ; font-size: 14px;">
        您确定删吗？
    </div>
    <div class="modal-footer" style="padding: 8px 0; text-align: center;">
        <a href="javascript:;" class="btn btn-small btn-primary delok" data-dismiss="modal">确定</a>
        <a href="javascript:;" class="btn btn-small delcancle" data-dismiss="modal">取消</a>
    </div>
</div>
<!--弹出窗口end-->

<!--弹出窗口alert begain-->
<div id="alertDialog" class="modal hide dialog">
    <div class="modal-header">
        <a class="close" data-dismiss="modal">&times;</a>
        <h5 style="color: #555;">提示信息</h5>
    </div>
    <div class="modal-body" style="text-align: center; padding: 15px; 0 ; font-size: 14px;">
        该部门下还有在职员工，不能被删除
    </div>
    <div class="modal-footer" style="padding: 8px 0; text-align: center;">
        <a href="javascript:;" class="btn btn-small btn-primary" data-dismiss="modal">确定</a>
    </div>
</div>
<!--弹出窗口alert end-->
    
<?php $this->script_block_begin();?>
<script language="javascript" type="text/javascript">
    //$("#aaa").alert()
    var editURL = '<?=Util_BaseUrls::ajax_dep_update()?>';
    var addURL = '<?=Util_BaseUrls::ajax_dep_add()?>';
    var delURL = '<?=Util_BaseUrls::ajax_dep_delete()?>';
</script>
<?php $this->script_block_end();?>